package com.atguigu.gmall.all.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.client.ItemFeignClient;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Map;

/**
 * @author Fxz
 * @version 1.0
 * @date 2022-02-08 11:37
 */
@Controller
@RequiredArgsConstructor
public class ItemController {

	private final ItemFeignClient itemFeignClient;

	@RequestMapping("{skuId}.html")
	public String skuItem(@PathVariable Long skuId, Model model) {
		Result<Map<String, Object>> result = itemFeignClient.getItemById(skuId);
		model.addAllAttributes(result.getData());
		return "item/index";
	}

}
